[type layout] usize and isize have the same size and alignment#2200
[type layout] usize and isize have the same size and alignment#2200joshlf wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
r? @RalfJung |
|
Failed to set assignee to
|
|
r? @ehuss |
|
Makes sense. It is a new language guarantee, though, so... @rfcbot fcp merge lang |
This comment was marked as duplicate.
This comment was marked as duplicate.
|
Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
Is there an equivalent statement about alignment that |
No. I'd be happy to relax this to just saying that sizes are equal, which is really what I (personally) care about. |
|
TBH I think that both are obvious things to provide. Was just seeing that we have the size equality guarantees for (I have no strong feelings about the best way to do that. If you wanted to just just make this be size that's fine; if you wanted to just open another PR to also give the alignment guarantee for the specific-sized integer types that'd also be fine.) |
|
Oh I'm totally happy guaranteeing both. From my perspective, more guarantees is always better. But I didn't know if there was some reason that the language might want to keep this option open – maybe theres' some weird opsem thing I don't know about (cc @RalfJung) or some weird architecture on which these two have different alignments. For example, there's that MSVC thing where its allocator allocates 8-byte-aligned values at 4 byte alignment – maybe there's some architecture where LLVM lowers signed values differently than unsigned ones or something weird like that. |
|
If we end up deciding we're okay with alignment, I'd also be happy to update this PR to guarantee alignment equality b/w all |
|
No weird opsem thing I am aware of (LLVM doesn't even know the sign of our integers most of the time). But the potential for weird architectures is of course unbounded and that's not my expertise. That said, AFAIK the LLVM data layout string cannot even represent sign-dependent alignment so it seems unlikely that LLVM could work on a target where integers with the same size and different sign have different alignment. Cc @nikic |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
I think there should be. |
Yes, LLVM data layout is sign independent. Technically, Clang could use different alignment based on signedness, in much the same way |
|
@rfcbot reviewed god I hope this is not controversial |
|
@rfcbot reviewed |
|
From the lang meeting: please also make another PR to add the (Rather than needing to change this one that's already in FCP.) |
|
Put up #2205 to guarantee |
Everybody assumes this to be true, and I assume it was intended to be guaranteed to be true.